//
//  DDTabbarView.m
//  QQZone
//
//  Created by 树清吴 on 2017/10/16.
//  Copyright © 2017年 shuQingWu. All rights reserved.
//

#import "DDTabbarView.h"

@implementation DDTabbarView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = DDGrayColor;
        
        UIButton *btn1 = [UIButton buttonWithTitle:nil image:@"tabbar_blog" highlighted:nil background:nil backgroundHighlighted:nil target:nil action:nil];
        [self addSubview:btn1];
        UIButton *btn2 = [UIButton buttonWithTitle:nil image:@"tabbar_photo-1" highlighted:nil background:nil backgroundHighlighted:nil target:nil action:nil];
        [self addSubview:btn2];
        UIButton *btn3 = [UIButton buttonWithTitle:nil image:@"tabbar_photo" highlighted:nil background:nil backgroundHighlighted:nil target:nil action:nil];
        [self addSubview:btn3];
        

    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    NSInteger count = self.subviews.count;
    CGFloat width = 0;
    CGFloat height = 0;
    CGFloat x = 0;
    CGFloat y = 0;
    for (int i = 0; i < count; i ++) {
        UIButton *btn = self.subviews[i];
        if (DDPortrait) {
            width = self.width;
            height = width;
            y = i * height;
        }else{
            width = self.width / count;
            height = width;
            x = i * width;
        }
        btn.frame = CGRectMake(x, y, width, height);
    }

}


@end
